import {
  createRouter,
  createWebHashHistory /* 或 createWebHistory */,
} from "vue-router";

import UserIndex from "../views/UserIndex.vue";
import BusinessList from "../views/BusinessList.vue";
import BusinessInfo from "../views/BusinessInfo.vue";
import Login from "../views/Login.vue";
import Orders from "../views/Orders.vue";
import UserAddress from "../views/UserAddress.vue";
import Payment from "../views/Payment.vue";
import OrderList from "../views/OrderList.vue";
import AddUserAddress from "../views/AddUserAddress.vue";
import EditUserAddress from "../views/EditUserAddress.vue";
import Register from "../views/Register.vue";
import BusinessLogin from "../views/BusinessLogin.vue";
import BusinessRegister from "../views/BusinessRegister.vue";
import ProductManagement from "../views/ProductManagement.vue";
import My from "../views/My.vue";
import UserComments from "@/views/UserComments.vue";
import Password from "../views/Password.vue";
import AdministratorIndex from "../views/AdministratorIndex.vue";
import AdministratorToUser from "../views/AdministratorToUser.vue";
import AdministratorToBusiness from "../views/AdministratorToBusiness.vue";
import AdministratorToAppeal from "../views/AdministratorToAppeal.vue";
import HongbaoAdvertisement from "../views/HongbaoAdvertisement.vue";
import BusinessSearch from "../views/BusinessSearch.vue";
import AIAssitant from "@/views/AIAssitant.vue";

const routes = [
  {
    path: "/",
    name: "Home",
    component: UserIndex,
  },
  {
    path: "/userIndex",
    name: "UserIndex",
    component: UserIndex,
  },
  {
    path: "/businessList",
    name: "BusinessList",
    component: BusinessList,
  },
  {
    path: "/businessInfo",
    name: "BusinessInfo",
    component: BusinessInfo,
  },
  {
    path: "/login",
    name: "Login",
    component: Login,
  },
  {
    path: "/orders",
    name: "Orders",
    component: Orders,
  },
  {
    path: "/userAddress",
    name: "UserAddress",
    component: UserAddress,
  },
  {
    path: "/payment",
    name: "Payment",
    component: Payment,
  },
  {
    path: "/orderList",
    name: "OrderList",
    component: OrderList,
  },
  {
    path: "/addUserAddress",
    name: "AddUserAddress",
    component: AddUserAddress,
  },
  {
    path: "/editUserAddress",
    name: "EditUserAddress",
    component: EditUserAddress,
  },
  {
    path: "/register",
    name: "Register",
    component: Register,
  },
  {
    path: "/businessLogin",
    name: "BusinessLogin",
    component: BusinessLogin,
  },
  {
    path: "/businessRegister",
    name: "BusinessRegister",
    component: BusinessRegister,
  },
  {
    path: "/productManagement",
    name: "ProductManagement",
    component: ProductManagement,
  },
  {
    path: "/my",
    name: "My",
    component: My,
  },
  {
    path: "/password",
    name: "Password",
    component: Password,
  },
  {
    path: "/administratorIndex",
    name: "AdministratorIndex",
    component: AdministratorIndex,
  },
  {
    path: "/administratorToUser",
    name: "AdministratorToUser",
    component: AdministratorToUser,
  },
  {
    path: "/administratorToBusiness",
    name: "AdministratorToBusiness",
    component: AdministratorToBusiness,
  },
  {
    path: "/administratorToAppeal",
    name: "AdministratorToAppeal",
    component: AdministratorToAppeal,
  },
  {
    path: "/hongbao",
    name: "HongbaoAdvertisement",
    component: HongbaoAdvertisement,
  },
  {
    path: "/usercomments",
    name: "UserComments",
    component: UserComments,
  },
  {
    path: "/businessSearch",
    name: "BusinessSearch",
    component: BusinessSearch,
  },
  {
    path: "/aiAssistant",
    name: "AIAssistant",
    component: AIAssitant,
  }
];

// v4 不要再覆盖 push 以吞掉错误

const router = createRouter({
  // 为避免服务端改造，先用 Hash 路由
  history: createWebHashHistory(),
  // 如需 History 模式：history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;
